package main

import (
    "fmt"
)

type Person interface {
	show()
}

type XiaoMing struct {
	Person
}

func (xm *XiaoMing) show() {
	fmt.Println("我是小明")
}

type Decorate struct {
	Person
	person Person
}

func (d *Decorate) show() {
	if d.person != nil {
		d.person.show()
	}
}

type Shirt struct {
	Decorate
}

func (s *Shirt) show() {
	fmt.Println("穿衬衫")
}

type Trouser struct {
	Decorate
}

func (s *Trouser) show() {
	fmt.Println("穿西裤")
}

func main() {
	var p Person = new(XiaoMing)
	p.show()
	s := &Shirt{}
	s.person = p
	s.show()
	t := &Trouser{}
	t.person = s
	t.show()
}
